<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>外边距合并</title>
    <style>
        .c1{
            width: 200px;
            height: 100px;
            background-color: red;
            margin-bottom: 30px;
        }
        .c2{
            width: 200px;
            height: 100px;
            background-color: green;
            margin-top: 20px;
        }
        .c3{
            width: 500px;
            height: 200px;
            background: red;
            margin: 10px auto;
            /*border: 1px solid red;*/
            /*padding: 10px;*/
        }
        .c4{
            width: 100px;
            height: 100px;
            background: green;
            margin-top: 50px;
        }
    </style>
</head>
<body>
<div class="c1"></div>
<div class="c2"></div>
<hr>
<div class="c3">
    <div class="c4"></div>
</div>
</body>
</html>